package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.TravelAgencyAuditDetail;
import com.example.mountainwalker.entity.TravelAgencyImageInfo;
import com.example.mountainwalker.service.TravelAgencyAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/mw")
public class TravelAgencyAuditController {

    @Autowired
    private TravelAgencyAuditService travelAgencyAuditService;

    @GetMapping("/travelAgencyBasicDetail/{id}")
    public TravelAgencyAuditDetail getTravelAgencyBasicDetail(@PathVariable Integer id) {
        return travelAgencyAuditService.getTravelAgencyDetailById(id);
    }

    @PostMapping("/approveTravelAgency")
    public int approveTravelAgency(@RequestBody AuditRequest request) {
        return travelAgencyAuditService.updateAuditStatus(request.getId(), "通过");
    }

    @PostMapping("/rejectTravelAgency")
    public int rejectTravelAgency(@RequestBody AuditRequest request) {
        return travelAgencyAuditService.updateAuditStatus(request.getId(), "未通过");
    }

    // Response wrapper class
    private static class TravelAgencyAuditResponse {
        private TravelAgencyAuditDetail agencyInfo;
        private List<TravelAgencyImageInfo> images;

        public TravelAgencyAuditResponse(TravelAgencyAuditDetail agencyInfo, List<TravelAgencyImageInfo> images) {
            this.agencyInfo = agencyInfo;
            this.images = images;
        }

        // Getters
        public TravelAgencyAuditDetail getAgencyInfo() {
            return agencyInfo;
        }

        public List<TravelAgencyImageInfo> getImages() {
            return images;
        }
    }

    // Request wrapper class
    private static class AuditRequest {
        private Integer id;
        private String status;

        // Getters and Setters
        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }
    }
}